/**
 * Copyright (c) 2012, Brent Mucci
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/


#ifndef _MCL_BITSTREAM
#define _MCL_BITSTREAM

namespace mcl 
{

class Bitstream
{
public:
	// *** See ITU-T June 2011 specification on the following methods:
	virtual ~Bitstream() {};
	virtual bool byte_aligned() = 0;
	virtual bool more_data_in_byte_stream() = 0;
	virtual bool more_rbsp_data() = 0;
	virtual bool more_rbsp_trailing_data() = 0;
	virtual void rbsp_trailing_bits() = 0;
	virtual unsigned int next_bits(unsigned int n) = 0;
	virtual unsigned int read_bits(unsigned int n) = 0;
	// Read unsigned exponential golomb encoded bits
	virtual unsigned int read_bits_ue() = 0;
	// Read signed exponential golomb encoded bits
	virtual signed int read_bits_se() = 0;

protected:
	// Once data has been read in, step the bitstream bit position forward.
	virtual void step(unsigned int bits) = 0;
	// Return an integer containing a number of bits that have been peeked.
	virtual unsigned int peek(unsigned int bits) = 0;
	// The number of bits necessary to reach the next byte alignment.
	virtual unsigned int bitsToAlign() = 0;
};
};

#endif
